//
//  FeedVM.swift
//  SlaughterClient
//
//  Created by 邱仙凯 on 2020/2/12.
//  Copyright © 2020 zwb. All rights reserved.
//

import UIKit
 
class ZyaFeedVM: NSObject {

    
    func getZTBUnit(end:@escaping Action) {
      
        KSNetwork.shared.doRequest(API.getUnitDic) { (data:BaseResult<unitModel>) in
            if data.flag == TRUE {
                if let infos = data.infos {
                    UnitArr.removeAll()
                    UnitArr += infos
                }
                
            } else {
                KSToast(data.message.unwrap)
            }
            end()
            
        }
    }
    func getProtocol(end:@escaping Action) {
      
        KSNetwork.shared.doRequest(API.queryProtocol) { (data:BaseResult<ProtocolResult>) in
            if data.flag == TRUE {
                if let infos = data.infoArrCombine {
                    protocolArr = infos
                }
             } else {
                KSToast(data.message.unwrap)
            }
            end()
            
        }
    }
    // 获取\(memStr.unicode2Str())信息
    func getMember() {
        KSNetwork.shared.doRequest(API.queryMemberInfo(client_id: USERINFO.usrid.unwrap)) { (data:BaseResult<MeInfoModel>) in
            if data.flag == TRUE {
                if let info = data.info_object {
                    meInfoM = info
                   }
             }
         }
    }
    // 获取权益信息
    func queryEquity()  {
        KSNetwork.shared.doRequest(API.queryEquity(member_type: "")) { (data:BaseResult<EquityModel>) in
            if data.flag == TRUE {
                if let infos = data.infos {
                    zyaequityArr = infos
                }
            }
        }
    }
    func getDefaultAddr() {
        KSNetwork.shared.doRequest(API.queryClientAddress(k_addr_type: "1")) { (data: BaseResult<ZyaClientAddress>) in
            if let infos = data.infoArrCombine {
                zyasendAddrArr = infos
            }
            
         }
        KSNetwork.shared.doRequest(API.queryClientAddress(k_addr_type: "0")) { (data: BaseResult<ZyaClientAddress>) in
             if let infos = data.infoArrCombine {
                zyareceiveAddrArr = infos
            }
         }
    }

}
func zyagetUserInfo(end:@escaping Action) {
     
    KSNetwork.shared.doRequest(API.getUserInfoForUpdate(idkey: USERINFO.usrid.unwrap)) { (data:BaseResult<RegisterModel>) in
           if data.flag == TRUE {
            if let info = data.info_object {
                PersonTempInfo = info
            }
               
           } else {
               KSToast(data.message.unwrap)
           }
           end()
           
       }
   }
